package com.gxa.insurance.controller;

import com.gxa.insurance.exception.BusinessException;
import com.gxa.insurance.pojo.CarBrand;
import com.gxa.insurance.pojo.ThirdAdmin;
import com.gxa.insurance.service.CarBrandService;
import com.gxa.insurance.util.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author 10076
 */

@Api(value = "汽车品牌接口")
@RestController
@RequestMapping("/CarType")
@CrossOrigin
public class CarBrandController {
    @Autowired
    private CarBrandService carBrandService;

    @ApiOperation(value = "查询所有汽车品牌",produces = "query")
    @PostMapping("/selectCarType")
    public Map select() throws Exception {
        List<String> list = carBrandService.selectAll();
        JsonResult jsonResult =new JsonResult();
        jsonResult.setData(list);
        jsonResult.setCode("200");
        return jsonResult.getMap();
    }
    @ApiOperation(value = "通过名字查询汽车品牌",produces = "query")
    @PostMapping("/selectCarTypeName")
    public Map selectByName(@RequestParam("carname") String carname) throws Exception {
        List<String> list = carBrandService.selectAllByname(carname);
        JsonResult jsonResult =new JsonResult();
        jsonResult.setData(list);
        jsonResult.setCode("200");
        return jsonResult.getMap();
    }
}
